package org.ht.util;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Vector;

public class CaseUtil {
	public static Vector<Object> convertRow(Vector<Object> row) {
		Vector<Object> v = new Vector<Object>(row);
		for (int i = 0; i < v.size(); i++) {
			Object obj = v.get(i);
			if (obj instanceof String) {
				String newobj = (String) obj;
				switch (newobj) {
				case "true":
					v.set(i, "是");
					break;
				case "false":
					v.set(i, "否");
					break;
				default:
					break;
				}
			}
		}
		return v;
	}

	public static void fillCase(Map<String, String> target,
			Map<String, Object> map) {
		Map<String, String> newmap = new HashMap<String, String>();
		if (map == null) {
			return;
		} else {
			for (Entry<String, Object> e : map.entrySet()) {
				String key = e.getKey();
				key = key.substring(key.lastIndexOf('.') + 1);
				newmap.put(key, e.getValue().toString().trim());
			}
			for (Entry<String, String> e : target.entrySet()) {
				String key = e.getKey();
				String value = newmap.get(key.toUpperCase());
				target.put(key, value);
			}
		}
		return;
	}
}
